function createCategoryView(){
	var data = createCategoryModel();
	createLoadCateNode(data.categories);
}

function createLoadCateNode (arrCate) {
		var key = "category";
		addActive(key);
		var rootNode = $id("loadCategories");
		rootNode.innerHTML = "";
		if (arrCate.length > 0) {
			var nodeTable = createTable();

			var nodeThId = createNode("th");
			var id = createTextNode("Mã");
			nodeThId.appendChild(id);
			var nodeThCateName = createNode("th");
			var catTh = createTextNode("Thể loại");
			nodeThCateName.appendChild(catTh);
			var nodeThUpdate = createNode("th");
			var nodeThDelete = createNode("th");

			nodeTable.appendChild(nodeThId);
			nodeTable.appendChild(nodeThCateName);
			nodeTable.appendChild(nodeThUpdate);
			nodeTable.appendChild(nodeThDelete);

			var length = arrCate.length;

			for (var i = 0; i < length; i++) {
				var nodeTr = null;

				var nodeCateId = null;
				var nodeCateName = null;
				var nodeTdUpdate = null;
				var nodeDivUpdate = null;
				var nodeUpdate = null;
				var nodeTdDelete = null;
				var nodeDivDelete = null;
				var nodeDelete = null;
				var cate = arrCate[i];

				nodeTr = createNode("tr");
				nodeTr.setAttribute("id", 'category' + cate.categoryId);

				nodeCateId = createNode("td");
				var id = createTextNode(cate.categoryId);
				nodeCateId.appendChild(id);

				nodeCateName = createNode("td");
				var cateName = createTextNode(cate.categoryName);
				nodeCateName.appendChild(cateName);

				//create node update
				nodeTdUpdate = createNode("td");
				nodeDivUpdate = createDiv();
				nodeUpdate = createNode("img");
				nodeUpdate.setAttribute("src", "Image/update.png");
				nodeUpdate.style.cursor = "pointer";
				nodeTdUpdate.addEventListener("click", function(event) {

					var currentRow = $id(event.currentTarget.parentNode.id);
					var cels = currentRow.getElementsByTagName("td");

					var cateID = cels[0].innerText;
					var cate = cels[1].innerText;
					var model = new CateModel(cateID, cate);
					showPage("content-updateCategory");
					showUpdateCategoryView(model);

				});

				nodeDivUpdate.appendChild(nodeUpdate);
				nodeTdUpdate.appendChild(nodeDivUpdate);

				nodeDelete = createNode("td");

				//create node delete
				nodeTdDelete = createNode("td");
				nodeDivDelete = createDiv();
				nodeDelete = createNode("img");
				nodeDelete.setAttribute("src", "Image/delete_icon.png");
				nodeDelete.style.cursor = "pointer";
				nodeTdDelete.addEventListener("click", function(event) {
					var row = $id(event.currentTarget.parentNode.id);
					var cels = row.getElementsByTagName("td");
					var cateID = cels[0].innerText;
					var r = confirm("Bạn có muốn xóa thể loại có mã là " + cateID);
					var x;
					if (r == true) {
						delCategory(cateID);
					}
				});
				nodeDivDelete.appendChild(nodeDelete);
				nodeTdDelete.appendChild(nodeDivDelete);

				nodeTr.appendChild(nodeCateId);
				nodeTr.appendChild(nodeCateName);
				nodeTr.appendChild(nodeTdUpdate);
				nodeTr.appendChild(nodeTdDelete);

				//nodeTr.appendChild(nodeTd);

				nodeTable.appendChild(nodeTr);

			}
			rootNode.appendChild(nodeTable);
			//het phan duyet dom tree
		}
	}
	
